package com.zzyl;

public class Singleton {

    private volatile static Singleton instance;

    private Singleton() {
    }

    public static Singleton getInstance() {
        if (instance==null) { //第一次检查
            synchronized (Singleton.class) {
                if (instance==null) { //第二次检查
                    instance=new Singleton();
                }
            }
        }
        return instance;
    }
}    